﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.ComponentModel;
using System.Globalization;

namespace MC34063_Universal_Calculator
{
    /// <summary>
    /// Interaktionslogik für MC34063A_StepUp_Page.xaml
    /// </summary>
    public partial class MC34063A_Invert_Page : Page, INotifyPropertyChanged
    {
        double _Vin;

        public double Vin
        {
            get { return _Vin; }
            set { _Vin = value; OnPropertyChanged("Vin"); }
        }
        double _Vout;

        public double Vout
        {
            get { return _Vout; }
            set { _Vout = value; OnPropertyChanged("Vout"); }
        }
        double _Rsc;

        public double Rsc
        {
            get { return _Rsc; }
            set { _Rsc = value; OnPropertyChanged("Rsc"); }
        }
        double _Rdriver;

        public double Rdriver
        {
            get { return _Rdriver; }
            set { _Rdriver = value; OnPropertyChanged("Rdriver"); }
        }
        double _L;

        public double L
        {
            get { return _L; }
            set { _L = value; OnPropertyChanged("L"); }
        }
        double _Cin;

        public double Cin
        {
            get { return _Cin; }
            set { _Cin = value; OnPropertyChanged("Cin"); }
        }
        double _Cout;

        public double Cout
        {
            get { return _Cout; }
            set { _Cout = value; OnPropertyChanged("Cout"); }
        }
        double _Ct;

        public double Ct
        {
            get { return _Ct; }
            set { _Ct = value; OnPropertyChanged("Ct"); }
        }
        string _D;

        public string D
        {
            get { return _D; }
            set { _D = value; OnPropertyChanged("D"); }
        }
        double _R1;

        public double R1
        {
            get { return _R1; }
            set { _R1 = value; OnPropertyChanged("R1"); }
        }
        double _R2;

        public double R2
        {
            get { return _R2; }
            set { _R2 = value; OnPropertyChanged("R2"); }
        }

        public MC34063A_Invert_Page(OutputData outData, InputData inpData)
            : this()
        {
            Vin = (inpData.Vinmax + inpData.Vinmin) / 2;
            Vout = outData.Vout;
            Rsc = outData.Rsc;
            Rdriver = outData.Rdriver;
            L = outData.L;
            D = inpData.SelectedDiodeValue.Name;
            Ct = outData.Ct;
            Cout = outData.Co;
            R1 = outData.R1;
            R2 = outData.R2;
        }

        public MC34063A_Invert_Page()
        {
            InitializeComponent();
            Cin = 100;
        }

        protected void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        public event MouseButtonEventHandler Click;

        protected void OnClick(MouseButtonEventArgs e)
        {
            if (Click != null)
            {
                Click(this, e);
            }
        }

        private void Page_MouseDown(object sender, MouseButtonEventArgs e)
        {
            OnClick(e);
        }

    }
}
